package middleware

import (
	"github.com/gin-gonic/gin"
	"order-srv/libs"
)

func Tracer() gin.HandlerFunc {
	return func(c *gin.Context) {
		tracer := libs.GetTracer()
		// 创建根 span
		parentSpan := tracer.StartSpan(c.Request.URL.Path)
		// 最后父 span 结束
		defer parentSpan.Finish()
		//c.Set("TracerSpan", []interface{}{tracer, parentSpan})
		c.Set("parentSpan", parentSpan)
		c.Next()
	}
}
